import java.awt.Color;
import java.awt.GridLayout;
import java.rmi.RemoteException;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTextArea;

public class ServerApplication extends JFrame {

	WhiteBoardServer server;

	JTextArea messageArea;
	JScrollPane scroller;
	WhiteBoard drawingSurface;

	public ServerApplication(WhiteBoardServer s) {
		super();
		server = s;
		
//		setLayout(new GridLayout(2, 1));
		messageArea = new JTextArea();
		messageArea.setEditable(false);
		messageArea.setForeground(Color.GRAY);
		messageArea.append("Server started...");
		drawingSurface = server.getBoard();
		scroller = new JScrollPane(messageArea);

		JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
                drawingSurface, scroller);
		splitPane.setDividerLocation(200);
		this.add(splitPane);
	}

	public void appendMessage(String s){
		messageArea.append("\n"+s);
		messageArea.repaint();
	}
	public static void main(String[] args) throws RemoteException {
		WhiteBoardServer s = new WhiteBoardServer();
		
		ServerApplication sa = new ServerApplication(s);
		s.setSlave(sa);
		// JFrame f = new JFrame(title);
		sa.setAlwaysOnTop(true);
		sa.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		sa.setSize(400, 400);
		sa.setVisible(true);

	}

}
